package com.ruoyi.system.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.service.ISmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = {"短信发送"})
@RestController
@RequestMapping("/edusms/sms")
@CrossOrigin
public class SmsController {
    @Autowired
    private ISmsService smsService;

    @ApiOperation(value = "发送短信的方法")
    @GetMapping("send/{phone}")
    public R sendSms(
            @ApiParam(name = "phone",value = "手机号码",required = true)
            @PathVariable String phone
    ){
        //调用service发送短信的方法
        boolean isSend = smsService.send(phone);
        if (isSend){
            return R.ok();
        }else {
            return R.fail();
        }
    }
}

